package fieldmaps.voronoi;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class ConnectionVoronoi {
	public static String driver = "org.postgresql.Driver";
	public static String connectString = "jdbc:postgresql://localhost:5432/field_maps";
	public static String user = "postgres";
	public static String password = "1234";
	
	public static void main(String[] args) {

		try {
			Class.forName(driver);
			Connection conn = DriverManager.getConnection(connectString, user,password);
			String query = "SELECT gid, ST_AsText(the_geom) AS the_geom FROM etrs_laea_grid_polys WHERE gid = 1;";
			Statement st = conn.createStatement();
			ResultSet rs = st.executeQuery(query);
			
		    try	{
			    while (rs.next()) {
				    String id = rs.getString("gid");
				    String geom = rs.getString("the_geom");
				    System.out.println(id + "   " + geom);
			    }
		    } catch (Exception e) {
		    	System.out.println(e.getMessage());
			}
		    
			st.close();
			conn.close();
		}
		catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}
}
